var app = getApp(),
  $ = require("../../utils/httpHelper.js")
var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
Page({
  data: {
    height:0,
    coupon_id:0
  },
  onLoad: function (options) {
    var that = this;
    console.log(options)
    
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        that.setData({
           width: res.windowWidth-20,
           height:res.windowHeight })
      }
    })
    if (options.scene){
      this.setData({
        coupon_id: options.scene 
      })
    }
    

  },

  subuse() {
    $.httpPost("consume_coupon", { rd_session: wx.getStorageSync('rd_session'), coupon_id:this.data.coupon_id}, (data, err) => {
      if(data.result == 'success'){
        wx.switchTab({
          url: '/pages/index/index',
        })
      }else{
        wx.showToast({
          title: data.message,
        })
      }
      
    })
  },
});